import 'package:ca_dsp_pro/src/common/db_item.dart';
import 'package:ca_dsp_pro/src/modules/input/my_input_controller.dart';
import 'package:ca_dsp_pro/src/tool/assets.dart';
import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';

class MyInput extends SumPageDelegate<MyInputController> {
  MyInput({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color_bg_view,
      padding: const EdgeInsets.all(5),
      child: Row(
        children: [
          Expanded(
            child: LayoutBuilder(builder: (BuildContext con, BoxConstraints constraints) {
              return Obx(() {
                return Container(
                  padding: EdgeInsets.only(left: constraints.maxWidth / 3, right: constraints.maxWidth / 3),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    children: controller.items.asMap().entries.map(($0) {
                      final iscurrent = controller.currentItem.value == $0.key;
                      return myTextButton(
                        height: 70,
                        select: iscurrent,
                        colors: iscurrent ? [Color_theme.withAlpha(180), Color_theme] : [Color_bar, Color_bar],
                        borderColor: iscurrent ? Color_theme : Color_bar,
                        color: Color_bar,
                        child: Center(
                          child: Text(
                            $0.value,
                            textAlign: TextAlign.center,
                            style: const TextStyle(color: Colors.white, fontSize: 30, fontWeight: FontWeight.bold),
                          ),
                        ),
                        onTap: () => controller.selectionTag($0.key, context),
                      );
                    }).toList(),
                  ),
                );
              });
            }),
          ),
          SizedBox(
            width: 100,
            child: Obx(() {
              return DbItem(
                name: 'MASTER LEVEL',
                max: globalController.rxModel.value.master_lv!.max_db.toDouble(),
                min: globalController.rxModel.value.master_lv!.min_db.toDouble(),
                value: globalController.rxModel.value.master_lv!.db.toDouble(),
                ison: controller.ison.value,
                onChanged: (value, issend) => controller.updateDB(value, issend: issend),
                onTurnOn: (p0) => controller.turnVoice(),
              );
            }),
          ),
        ],
      ),
    );
  }
}
